﻿<UserControl x:Class="PairingMatrix.View.TeamMemberCardControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Behavior="clr-namespace:PairingMatrix.View.Behavior" xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:AttachedProperty="clr-namespace:PairingMatrix.View.AttachedProperty" xmlns:Converter="clr-namespace:PairingMatrix.View.Converter" mc:Ignorable="d" d:Height="300" d:Width="300"  d:DataContext="{Binding Source={StaticResource TeamMember}}" HorizontalAlignment="Left">
	<UserControl.Resources>
		<Converter:BoolToVisibilityConverter x:Key="boolToVisibilityConverter" />
        <Converter:PairingLevelToColorConverter x:Key="pairingLevelToColorConverter" />
        <Converter:PairingLevelToBrushConverter x:Key="pairingLevelToBrushConverter" />
	</UserControl.Resources>
    <Grid Name="LayoutRoot" HorizontalAlignment="Left">
		<Grid Name="PairedWithCollection" Visibility="Collapsed" Opacity="0">
            <ItemsControl ItemsSource="{Binding Path=PairedWith}" Name="pairs" >
				<ItemsControl.ItemTemplate>
					<DataTemplate>
						<Grid>
							<Border>
								<Border.Effect>
                                    <DropShadowEffect BlurRadius="40" Color="{Binding Path=PairingLevel, Converter={StaticResource pairingLevelToColorConverter}}" Direction="310" Opacity="1" ShadowDepth="10" />
								</Border.Effect>
								<Grid HorizontalAlignment="Left" VerticalAlignment="Top">
									<Grid Background="White" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="55" Width="50">
										<Image Source="{Binding Path=Member.PhotoUri}" Stretch="Uniform" Height="40" Width="40" HorizontalAlignment="Center" Margin="0,5,0,0" VerticalAlignment="Top" />
										<TextBlock Text="{Binding Path=Member.Name}" Height="15" Width="60" HorizontalAlignment="Left" Margin="4,0,0,-3" VerticalAlignment="Bottom" FontWeight="Normal" FontFamily="Fonts/Fonts.zip#Consolas" FontSize="10" TextAlignment="Center" />
									</Grid>
								</Grid>
							</Border>
							<TextBlock Text="{Binding Path=NumberOfTimesPaired}" Height="20" Width="45" HorizontalAlignment="Left" Margin="4,0,0,-20" VerticalAlignment="Bottom" FontWeight="Normal" FontFamily="Fonts/Fonts.zip#Consolas" FontSize="18" TextAlignment="Center" />
							<!--                            <Button Content="+" Height="20" Width="20" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,-10,-15" Command="{Binding Path=IncrementPairing}"/>-->
							<Interactivity:Interaction.Behaviors>
								<Behavior:ArrangePairBehavior />
							</Interactivity:Interaction.Behaviors>
						</Grid>
					</DataTemplate>
				</ItemsControl.ItemTemplate>
				<ItemsControl.ItemsPanel>
					<ItemsPanelTemplate>
						<Canvas />
					</ItemsPanelTemplate>
				</ItemsControl.ItemsPanel>
			</ItemsControl>

            <ItemsControl ItemsSource="{Binding Path=ProjectCardAssignments}" Name="assignment" >
					<ItemsControl.ItemTemplate>
						<DataTemplate>
							<Grid>
                            <Rectangle Height="25" Width="100" Fill="#FFE2E254" Stroke="#FFC1C145" RadiusX="5" RadiusY="5" Margin="-10,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" />
                            <TextBlock Text="{Binding Path=Date}" Height="15" Width="100" HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Normal" FontFamily="Fonts/Fonts.zip#Consolas" FontSize="16" TextAlignment="Center" />
                            <Rectangle Height="25" Width="1000" Fill="#FFE2E254" Stroke="#FFC1C145" RadiusX="5" RadiusY="5" Margin="100,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" />
                            <TextBlock Text="{Binding Path=CardNumbers}" Height="15" Margin="110,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Normal" FontFamily="Fonts/Fonts.zip#Consolas" FontSize="16" TextAlignment="Center" />
                            <Interactivity:Interaction.Behaviors>
                                <Behavior:ArrangeProjectAssignmentsBehavior />
                            </Interactivity:Interaction.Behaviors>
                        </Grid>
						</DataTemplate> 
					</ItemsControl.ItemTemplate>
					<ItemsControl.ItemsPanel>
						<ItemsPanelTemplate>
                            <Canvas />
                        </ItemsPanelTemplate>
					</ItemsControl.ItemsPanel>
				</ItemsControl>
		</Grid>


        <Grid Margin="150,50,0,0" Name="IceCreamCollection" Visibility="{Binding Path=ArrangeCardToShowIceCreamMeter, Converter={StaticResource boolToVisibilityConverter}}" Opacity="1" HorizontalAlignment="Left">
            <ItemsControl ItemsSource="{Binding Path=IceCreams}" Name="iceCreams" >
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
                            <TextBlock Text="{Binding}" Foreground="LightGray" FontFamily="Fonts/Fonts.zip#Consolas" FontSize="10" HorizontalAlignment="Center" />
                            <Image Source="Image/IceCreamBar.png" Stretch="Uniform" Height="40" Width="40" HorizontalAlignment="Center" Margin="0,5,0,0" />
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </Grid>


        <Border HorizontalAlignment="Left">
			<Border.Effect>
				<DropShadowEffect BlurRadius="10" Color="Black" Direction="235" Opacity=".5" ShadowDepth="0" />
			</Border.Effect>
            <Grid>
                <Grid VerticalAlignment="Top" Margin="0" Visibility="{Binding Path=ShowNumberOfDaysPairedWithSelectedTeamMember, Converter={StaticResource boolToVisibilityConverter}}">
                    <Ellipse Width="40" Height="30" VerticalAlignment="Top" Fill="{Binding Path=PairingLevelWithSelectedTeamMember, Converter={StaticResource pairingLevelToBrushConverter}}" />
                    <TextBlock Text="{Binding Path=NumberOfSignUpsWithSelectedTeamMember}" HorizontalAlignment="Center" VerticalAlignment="Top" FontFamily="Fonts/Fonts.zip#Consolas" FontSize="19" />
                </Grid>

			    <Grid Name="titleBar" Background="White" MouseLeftButtonDown="titleBar_MouseLeftButtonDown" HorizontalAlignment="Center" VerticalAlignment="Center" Height="105" Width="100" Margin="0,22,0,0">
                    <Image Source="{Binding Path=PhotoUri}" Stretch="Uniform" x:FieldModifier="public" Height="80" HorizontalAlignment="Center" Margin="11,5,9,0" Name="imgPhoto" VerticalAlignment="Top" Width="80" MouseLeftButtonDown="imgPhoto_MouseLeftButtonDown" Cursor="Hand" />
				    <TextBlock Text="{Binding Path=Name}" Height="20" HorizontalAlignment="Center" Margin="0,0,0,-3" Name="txtCaption" VerticalAlignment="Bottom" Width="100" FontWeight="Normal" FontFamily="Fonts/Fonts.zip#Consolas" FontSize="14" TextAlignment="Center" />
				    <TextBox Height="22" HorizontalAlignment="Center" Margin="0,0,0,-3" Name="name" VerticalAlignment="Bottom" Width="100" FontWeight="Normal" FontFamily="Fonts/Fonts.zip#Consolas" FontSize="14" TextAlignment="Center" Text="{Binding Path=Name, Mode=TwoWay}" AttachedProperty:BindingHelper.UpdateSourceOnChange="True" IsEnabled="{Binding Path=IsInEditMode}" Visibility="{Binding Path=IsInEditMode, Converter={StaticResource boolToVisibilityConverter}}" IsEnabledChanged="name_IsEnabledChanged" />
				    <Button Command="{Binding Path=ToggleEditModeCommand}" Content="*" FontSize="20" Margin="0,5,2,0" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="18" Width="18" />
				    <!--                <Button Command="{Binding Path=DeleteCommand}" Content="X" FontSize="15" Margin="0,5,2,0" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="18" Width="18"/>-->
				    <Grid.RenderTransform>
					    <TransformGroup>
						    <ScaleTransform x:Name="rectTransform" ScaleY="1" ScaleX="1" />
					    </TransformGroup>
				    </Grid.RenderTransform>
			    </Grid>
            </Grid>
        </Border>

	</Grid>
	<Interactivity:Interaction.Behaviors>
		<Behavior:DragTeamMemberCardBehavior />
		<Behavior:MoveTeamMemberCardToShowPairingMatrixAndIceCreamMeterBehavior />
		<Behavior:CalculatePairPositionsBehavior />
		<!--        <Behavior:MoveAnimationForTeamMemberCardBehavior />-->
		<Behavior:ShowOrHideTeamMemberCardBehavior />
	</Interactivity:Interaction.Behaviors>
</UserControl>
